import Vue from 'vue'
import App from './App.vue'
import router from './router/index.js'
Vue.config.productionTip = false
import axios from 'axios'  // 安装axios后引入
Vue.prototype.$axios = axios  // 将axios挂载到原型上方便使用
//import store from './store/store.js'
import store from './store/login.js'


Vue.filter('dateFormat', (originVal) => {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + 1 + '').padStart(2, '0')
  const hh = (dt.getHours() + 1 + '').padStart(2, '0')
  const mm = (dt.getMinutes() + 1 + '').padStart(2, '0')
  const ss = (dt.getSeconds() + 1 + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

//console.log(Vue.prototype)

router.beforeEach((to, from, next) => {
  let token=window.sessionStorage.getItem('token')//相当于session
  
    //console.log(token)
    if (to.name != '/a') {
      if(token==null){
        //console.log(1)
        next({ name: '/a' }) 
      }
    }
    next()
})


new Vue({
  router,
  //storelogin,
  store,
  render: h => h(App),
}).$mount('#app')
